﻿//this file is part of OUP Project
//author : Tinn
//mail:
//Create Date:2010-11-11


var Oup = Oup ? Oup:{};

Oup.Http = Oup.Http ? Oup.Http:{};

//封装URL命名空间的方法

Oup.Http.URL = Oup.Http.URL? Oup.Http.URL:
{
	getString:function(str,ParamName)
	{
		var queryString = str.toLowerCase().substring(str.toLowerCase().indexOf("?") + 1);
        var parameters = queryString.split("&");
        
        var pos,paraName,paraValue;
        for(var i=0;i<parameters.length;i++)
        {
            pos = parameters[i].indexOf('=');
            if(pos == -1) continue;
            
            paraName = parameters[i].substring(0,pos);
            paraValue = parameters[i].substring(pos + 1);
            
            if(paraName.toLowerCase() == ParamName.toLowerCase())
            {
                return paraValue.replace(/\+/g, "");
            }
        }
        return '';
	},
	
    getQueryString:function(ParamName)
    {
        if (location.href.indexOf("?") == -1 || location.href.toLowerCase().indexOf(ParamName.toLowerCase() + '=') == -1)
        {
            return '';
        }

        var queryString = location.href.toLowerCase().substring(location.href.toLowerCase().indexOf("?") + 1);
        var parameters = queryString.split("&");
        
        var pos,paraName,paraValue;
        for(var i=0;i<parameters.length;i++)
        {
            pos = parameters[i].indexOf('=');
            if(pos == -1) continue;
            
            paraName = parameters[i].substring(0,pos);
            paraValue = parameters[i].substring(pos + 1);
            
            if(paraName.toLowerCase() == ParamName.toLowerCase())
            {
                return paraValue.replace(/\+/g, "");
                //return unescape(paraValue.replace(/\+/g,""));
                //return decodeURIComponent(paraValue.replace(/\+/g, ""));
            }
        }
        return '';
    },
    
    test:function(){
        alert('Tinn');
    }

}